FileUploader = require "./../../../common/file-uploader/index.coffee"

$ () ->
	imgKeyValue1 = null

	new FileUploader {
        click_button: "upload1_btn", # 点击后触发打开上传文件窗口的按钮，与类型为file的按钮绑定
        show_img: "cn_img1",                   # 上传成功后回显的图片ID
        domain: "http://ozjihfhke.bkt.clouddn.com",    # bucket 域名，下载资源时用到，**必需**
        browse_button: 'upload1',       # 上传选择的点选按钮ID，**必需**
        container: 'img-wrapper1',       # 上传区域DOM ID，默认是browser_button的父元素，**必需**
    }, {
        FileUploaded: (up, file, info)->
            imgKeyValue1 = info.key
    }

	$(".create_btn").click (e) ->
		param = 
			title:$("#title").val()
			abstract: $("#abstract").val()
			cover: imgKeyValue1
			content: $("#content").val()

		$.post '/api/admin/article/create',param,(res) ->
			if res.status.errCode is 0
				alert "添加成功"
			else
				alert res.status.message